﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace WindowsCountdownShutdownSoftware.Views
{
    /// <summary>
    /// MainView.xaml 的交互逻辑
    /// </summary>
    public partial class MainView : Window
    {
        public MainView()
        {
            InitializeComponent();
            progressBar.Maximum = 0;
        }

        /// <summary>
        /// 根据选择方式设置关机方式
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SelectMethod_Changed(object sender, SelectionChangedEventArgs e)
        {
            if (SelectBox == null || DateTimeBox == null || CountdownBox == null)
                return;

            if (SelectBox.SelectedIndex == 0)
            {
                this.DateTimeBox.Visibility = Visibility.Visible;
                this.CountdownBox.Visibility = Visibility.Collapsed;
            } else
            {
                this.DateTimeBox.Visibility = Visibility.Collapsed;
                this.CountdownBox.Visibility = Visibility.Visible;
            }
        }


        /// <summary>
        /// 最小化窗口事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MinimizeWindow_Click(object sender, RoutedEventArgs e)
        {
            // 在窗口类中（如MainWindow.xaml.cs）
            this.WindowState = WindowState.Minimized;
        }


        /// <summary>
        /// 标题栏拖动窗口
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void TitleBarMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            // 注意：在某些复杂界面中，直接调用DragMove()可能在某些区域引发异常，建议进行异常处理[citation:2]
            try
            {
                this.DragMove();
            }
            catch
            {
                // 处理异常
            }
        }

        ///// <summary>
        ///// 关闭当前程序
        ///// </summary>
        ///// <param name="sender"></param>
        ///// <param name="e"></param>
        //private void CloseSoftWare_Click(object sender, RoutedEventArgs e)
        //{
        //    // 关闭当前程序
        //    Environment.Exit(0);
        //}
    }
}
